﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Email.Subscription;

public partial class Member_Subscription_SubscriptionProductAdd : nspBase.MemberBasePge
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CheckCookies())
        {

        }
        else
            Response.Redirect("../../login/login.aspx");
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string Restr = "";
            SubscriptionProduct product = new SubscriptionProduct();
            product.UserID = int.Parse(GetCookie("UserID"));
            string myValue = "";
            if (Request.Form["ctl00$ContInfo$SortB"] != "" && Request.Form["ctl00$ContInfo$SortB"] != null)
            {
                myValue += Request.Form["ctl00$ContInfo$SortB"];
                myValue += ',' + Request.Form["ctl00$ContInfo$SortM"];
                myValue += ',' + Request.Form["ctl00$ContInfo$SortS"];
                product.Indtype = myValue;
            }
            else
                Restr = "产品所属类目、";
            myValue = "";
            if (txtKeyword.Text.Trim().Equals(string.Empty))
                Restr += "订阅关键字、";
            else
                product.Keyword = txtKeyword.Text.Trim();
            myValue += Request.Form["ctl00$ContInfo$province"] + ',';
            myValue += Request.Form["ctl00$ContInfo$city"] + ',';
            myValue += Request.Form["ctl00$ContInfo$county"];
            product.Area = myValue;
            product.Validity = int.Parse(dropValidity.SelectedValue);
            for (int i = 0; i < this.chklProduct.Items.Count; i++)
            {
                if (this.chklProduct.Items[i].Selected == true)
                {
                    product.Type = this.chklProduct.Items[i].Text;

                }
            }
            if (product.Type == null)
            {
                Restr += "商机类型";
            }
            if (Restr != "")
                Restr = Restr.TrimEnd('、');
            if (Restr == "")
            {
                product.Insert(product);
                ShowMessage("商机订阅成功！", "Subscription/SubscriptionProductList.aspx");
            }
            else
            {
                lblMessage.Visible = true;
                lblMessage.Text = Restr + "填写有误！";
            }
        }
        catch
        {
            ShowMessage("订阅供求信息失败!");
        }
    }
}
